#include <stdio.h>
#include <stdlib.h>
#include"menu_principal.h"
#include"personnel.h"
#include"patient1.h"
#include"ebola.h"


void menu_principal()
{
    int choix;
    int t1,t2;
    int n,n1,n2,n3;
    Personnel Per;
    Patient Pat;
char fper[MAX];
char fpat[MAX];
long int identifiant_personnel;
long int identifiant_patient;
char Events[50];
Parcours t[50];
char modele[50];

   do
   {
   system("clear");
   printf("\t\t<-->--------------------------------------<-->\n");
   printf("\t\t ||---                                  ---||\n");
   printf("\t\t ||-----       Menu Principal         -----||\n");
   printf("\t\t ||---                                  ---||\n");
   printf("\t\t<-->--------------------------------------<-->\n");
   printf("\t\t ||---                                  ---||\n");
   printf("\t\t ||      1 -->   Gerer  personnels         ||\n");
   printf("\t\t ||                                        ||\n");
   printf("\t\t ||      2 -->   Gerer  patients           ||\n");
   printf("\t\t ||                                        ||\n");
   printf("\t\t ||      3 -->   Analyse Events            ||\n");
   printf("\t\t ||                                        ||\n");
   printf("\t\t ||---                                  ---||\n");
   printf("\t\t ||      4 -->         Quitter             ||\n");
   printf("\t\t ||---                                  ---||\n");
   printf("\t\t<-->--------------------------------------<-->\n\n");
   printf("\t\t||--> Entrez votre choix :  ");
   scanf("%d",&choix);



   switch(choix)
   {
        case 1:
        {
        do
        {
        	system("clear");
   		printf("\n\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t ||----      ==  Menu Personnel  ==   ----||\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    1 -->  Enregistrer les personnels  ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    2 -->  Lister les personnels       ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    3 -->  Rechercher  personnel       ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    4 -->  Supprimer personnel         ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    5 -->  Modifier personnel          ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    6 -->  Modifier date sortie        ||\n");   
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    7 -->  Quitter                     ||\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n\n");
   		printf("\t\t\t||--> Entrez votre choix s'il vous plait : ");
   		scanf("%d",&n1);  
 
 		switch(n1)
		{
		case 1 :
		enregistrer_personnel("fper",&Per);
		break;
		case 2 :
		liste_personnel("fper");
		break;
		case 3 :
        	printf ("entrer l'identifiant du personnel à chercher\n");
        	scanf("%ld",&identifiant_personnel);
        	t1=rechercher_personnel("fper",identifiant_personnel);
        	if (t1==1) 
        	printf("\nle personnel existe\n ");
        	else printf("\nle personnel n'existe pas\n");
        	break;
		case 4 :
		supprimer_personnel(Per);
		break;
		case 5 :
		modifier_personnel(Per);
		break;
	
		case 6:
		modifier_date_sortie_personnel(Per);
		break;

		case 7 :	printf("\n\nvous quittez la page..\n\n");
        	break;
		default : printf("\n\nMauvais choix !\n\n");
			  break;
			  
		}
	}while(n1!=7);

	}//fermeture de case 1
           
            break;

       case 2:
		
	    {
	    do
            {   system("clear");
   		printf("\n\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
		printf("\t\t\t ||----      ==  Menu Patient  ==     ----||\n");
		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    1 -->  Enregistrer les patients    ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    2 -->  Lister les patients         ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    3 -->  Rechercher  patient         ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    4 -->  Supprimer  patient          ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    5 -->  Modifier patient            ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    6 -->  Modifier date sortie        ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    7 -->  Quitter                     ||\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n\n");
   		printf("\t\t\t||--> Entrez votre choix s'il vous plait : ");
   		scanf("%d",&n2);  
 
 		switch(n2)
		{
		case 1 :
	enregistrer_patient("fpat",&Pat);
	break;

case 2 :
	liste_patient("fpat");
	break;
	
case 3 :
        printf ("entrer l'identifiant du patient à chercher\n");
        scanf("%ld",&identifiant_patient);
        t2=rechercher_patient("fpat",identifiant_patient);
        if (t2==1) 
        printf("\nle patient existe\n ");
        else printf("\nle patient n'existe pas\n");
        break;
        
case 4 :
	supprimer_patient(Pat);
	break;

case 5 :
	modifier_patient(Pat);
	break;
	
case 6:
	modifier_date_sortie_patient(Pat);
	break;
	
case 7 :printf("\n\nvous quittez la page..\n\n");
        break;

default : 
	printf("\n\nMauvais choix !\n\n");
	break;
		}
	        }while(n2!=7);
	
	
	     }//fermeture de case 2
             break;
              
        
        case 3:
        {
        do
        {       
                printf("\n\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t ||----      ==  Menu Analyse Events  ----||\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    1 -->  Saisir modele               ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    2 -->  afficher parcours           ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    3 -->  afficher anomalie           ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||    4 -->  quitter                     ||\n");
   		printf("\t\t\t ||                                       ||\n");
   		printf("\t\t\t ||---                                 ---||\n");
   		printf("\t\t\t<-->-------------------------------------<-->\n\n");
   		printf("\t\t\t||--> Entrez votre choix s'il vous plait : ");
   		scanf("%d",&n3);  
 
 		switch(n3)
		{
		case 1 :system("clear");
		saisir_modele( modele);
		break;
		case 2 :system("clear");
		
		determiner_parcours(modele,t, "Events",&n);

                afficher_parcours(t,n);
                
		break;
		
        	case 3 :system("clear");
		afficher_anomalie( t, n, modele);
		break;

		case 4 :system("clear");
		printf("\n\nvous quittez la page..\n\n");
	        break;
	        
		default : printf("\n\nMauvais choix !\n\n");
		}
	}while(n3!=4);
        
         
      }//fermeture de case 3
      break;
      
      
      case 4 :
		{
		printf("\n\nvous quittez le programme..\n\n");
	        break;
	        }
		default : printf("\n\nMauvais choix !\n\n");
			  break;
		
		
	}	
	}while(choix!=4);
	
      }	
      
